using System.Collections.Generic;
using System.Linq;
using Managistics.Core.Infrastructure;
using Managistics.Core.Repositories;
using Managistics.Core.Services;
using Managistics.Model;

namespace Managistics.Core.Services.Impl
{
    public class BasicService : IBasicService
    {
        private readonly IGoodRepository _goodRepository;

        private readonly ISupplierRepository _supplierRepository;

        private readonly ICustomerRepository _customerRepository;

        private readonly IEmployeeRepository _employeeRepository;

        public BasicService(IGoodRepository goodRepository, ISupplierRepository supplierRepository, ICustomerRepository customerRepository, IEmployeeRepository employeeRepository)
        {
            _goodRepository = goodRepository;
            _supplierRepository = supplierRepository;
            _customerRepository = customerRepository;
            _employeeRepository = employeeRepository;
        }

        [UnitOfWork]
        public IList<Supplier> GetAllSuppliers()
        {
            return _supplierRepository.GetAll().OrderBy(s => s.Name).ToList();
        }

        [UnitOfWork]
        public IList<Customer> GetAllCustomers()
        {
            return _customerRepository.GetAll().OrderBy(c => c.Name).ToList();
        }

        [UnitOfWork]
        public IList<Employee> GetAllEmployees()
        {
            return _employeeRepository.GetAll().OrderBy(e => e.Lastname).ToList();// test
        }

        [UnitOfWork]
        public void Testing()
        {
            _goodRepository.GetAllParityGoods();
        }
    }
}